/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"805E36CF-8CBC-43B4-9EFD-8939F75D16DB"}
 */
function altaPaciente(event) {
	forms.pacientes_carga_dlg.controller.newRecord()
	forms.pacientes_carga_dlg.hospital_id = hospital_origen_id
	forms.pacientes_carga_dlg.hospital_ultimo_id = hospital_origen_id
	plugins.window.showFormPopup(elements.btn_nuevo, forms.pacientes_carga_dlg, foundset.getSelectedRecord(), 'paciente_id')
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"8407A758-4F1D-4E4F-92BE-23B263384EB1"}
 */
function onShow(firstShow, event) {
	databaseManager.setAutoSave(false)
	controller.newRecord()
	fecha = application.getServerTimeStamp()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"338AA3E4-0EB6-4DE2-A830-579F7A6C7084"}
 */
function confirmar(event) {
	
	if (paciente_id == null || codigo == null || hospital_origen_id == null)
	{
		globals.DIALOGS.showErrorDialog('Aviso','Por favor complete todos los datos','OK')
		return
	}
	
	if (databaseManager.saveData() == true)
	{
		globals.DIALOGS.showInfoDialog('Aviso','Muestra cargada correctamente','OK')
		salir()
	}
	else
	{
		globals.DIALOGS.showErrorDialog('Aviso','Ocurrio un error al grabar la muestra','OK')
	}
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"28BC3045-16CD-43DB-9243-B3BCF6758921"}
 */
function cancelar(event) {
	databaseManager.revertEditedRecords()
	salir()
}

/**
 * @properties={typeid:24,uuid:"EAFA2B66-DCE4-462A-9C07-6A2EB7B43A1D"}
 */
function salir()
{
	databaseManager.setAutoSave(true)
	var $win = application.getWindow('MUESTRA_CARGA')
	$win.hide()
	$win.destroy()
}
/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"AA7C84F1-B20B-4890-BA1F-D3C07DDA8F57"}
 */
function nuevoDestino(event) {
	muestras_to_muestra_destino.newRecord()
}
